<template>
	<view class="hui">
		<view class="head">
			<u-navbar :autoBack="true" :safeAreaInsetTop="true" :placeholder="true" bgColor="transparent">
				<view class="u-nav-slot b_flex_c" slot="center">
					<view class="city">客户订单</view>
				</view>
			</u-navbar>
		</view>
		
		<view class="tab_box" :style="'top:'+(top)+'px'">
			<u-tabs :scrollable='true' :list="tab" @click="click" lineColor="#4092F0" lineWidth="40"
				:activeStyle="{color:'#4092F0',fontWeight:'bold'}" :inactiveStyle="{color: '#454553'}"
				itemStyle='height:80rpx;'></u-tabs>
		</view>
		
		 <view style='height:40px'></view>
		
		<view class="lists_box">
			<view @click="$project.toPath('/pages/order/info?id='+item.id)" class="lists_info" v-for="(item,index) in list" :key="index">
				<view class="b_flex_c_s l_head">
					<view>订单编号:{{item.order_num}}</view>
					<view class="red">{{item.order_status_msg}}</view>
				</view>
				<view class="b_flex goods_box">
					<image v-if="item.goods[0]" class="l_img" :src="item.goods[0].goods_img"></image>
					<view class="goods_info">
						<view>
							<view class="l_name">{{item.goods[0].goods_name}}</view>
							<view class="l_time">下单时间: {{item.createtime}}</view>
						</view>

						<view class="l_msg"><text>共计{{item.count}}款商品 合计:</text><text class="money">￥{{item.hj}}</text></view>
					</view>
				</view>
				<view class="b_flex_c_s_end btn_box">
					<view class="btn">查看详情</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		glOrder
	} from '@/require/api';
	export default {
		data() {
			return {
				tab: [{
						val: '',
						name: '全部'
					},
					{
						val: '0',
						name: '待审核'
					},
					{
						name: '待支付',
						val: '1'
					},
					{
						name: '待发货',
						val: '2'
					},
					{
						name: '待分拣',
						val: '4'
					},
					{
						name: '待评价',
						val: '5'
					},
					{
						name: '已完成',
						val: '6'
					}
				],
				params: {
					page: 1,
					shenhe_status: ''
				},
				list: [],
				total: 0,
				emptyShow: false,
				top:0
			}
		},
		onShow() {
          this.top=uni.getSystemInfoSync().statusBarHeight+44;
		},
		onLoad() {
			this.getList();
		},
		methods: {
			click(e){
				this.params.shenhe_status=e.val;
				this.getList();
			},
			async getList() {
				this.params.page = 1;
				let {
					code,
					data
				} = await glOrder(this.params);

				if (code != 1) return;

				if (!data.data || data.data.length < 1) {
					this.emptyShow = true;
				} else {
					this.emptyShow = false;
				}
				this.list = data.data;
				this.total = data.total;
			}
		},
		onReachBottom() {
			if (this.list.length < this.total) {
				this.params.page++;
				glOrder(this.params).then(res => {
					res.data.data.forEach((res) => {
						this.list.push(res);
					});
				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	::v-deep {
		.u-navbar--fixed {
			background: linear-gradient(to bottom, #B9DDFF, #D7EAF3);
		}

		.u-tabs {

			background-color: white;
		}
	}

	.head {
		background: linear-gradient(to bottom, #B9DDFF, #D7EAF3);
	}

	.tab_box {
		background-color: white;
		position:fixed;
		top: 64px;
		left: 0;
		height: 80rpx;
	}

	.lists_box {
		box-sizing: border-box;
		padding: 30rpx 30rpx 1rpx 30rpx;
	}

	.lists_info {
		margin-bottom: 30rpx;
		background-color: white;
		border-radius: 10rpx;
	}

	.red {
		color: #F01D1D;
	}
	.money{
		color: #F01D1D;
		font-weight: bold;
		font-size: 30rpx;
	}

	.l_head {
		box-sizing: border-box;
		padding: 10rpx 20rpx;
		font-size: 26rpx;
		border-bottom: 1px solid #eee;
	}

	.goods_box {
		box-sizing: border-box;
		padding: 20rpx;
	}

	.l_img {
		width: 208rpx;
		height: 208rpx;
		border-radius: 10rpx;
		margin-right: 20rpx;
	}

	.l_name {
		font-weight: bold;

	}

	.l_time {
		font-size: 26rpx;
	}

	.l_msg {
		font-size: 22rpx;
		text-align: right;

	}

	.goods_info {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 64%;
	}
	.btn_box{
		border-top: 1px solid #efefef;
		    height: 96rpx;
		    line-height: 96rpx;
		    text-align: right;
		    padding-right: 20rpx;
	}
	.btn{
		    border-radius: 23rpx;
		    width: 140rpx;
		    display: inline-block;
		    height: 46rpx;
		    line-height: 46rpx;
		    margin-left: 20rpx;
		    font-size: 26rpx;
		    text-align: center;
			background: white;
			color: #333;
			border: 1px solid #333;
		}
		
		  
	
</style>